<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改设备问题报备')" />
    <th:block th:include="include :: datetimepicker-css" />
    	<th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-question-edit" th:object="${eQuestion}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">设备名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">问题描述：</label>
                <div class="col-sm-8">
                      <input id="question" name="question" th:field="*{question}" type="hidden">
                    <div id="editorQuestion" class="summernoteQuestion"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">要求：</label>
                <div class="col-sm-8">
                    <textarea name="require" class="form-control">[[*{require}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">报备人：</label>
                <div class="col-sm-8">
                    <input name="report" th:field="*{report}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">处理情况说明：</label>
                <div class="col-sm-8">
                    <input name="dealSay" th:field="*{dealSay}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">维修人：</label>
                <div class="col-sm-8">
                    <input name="repair" th:field="*{repair}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">维修时间：</label>
                <div class="col-sm-8">
                    <div class="input-group select-time">
                        <input name="repairTime" th:value="${#dates.format(eQuestion.repairTime, 'yyyy-MM-dd')}" class="time-input" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">待处理：</label>
                <div class="col-sm-8">
                    <input name="dealing" th:field="*{dealing}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">待处理说明：</label>
                <div class="col-sm-8">
                    <textarea name="dealingSay" class="form-control">[[*{dealingSay}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
<!--     <th:block th:include="include :: datetimepicker-js" /> -->
     <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/question";
        
        
	    $(function() {
		    $('.summernoteQuestion').summernote({
		    	placeholder: '请输入公告内容',
		    	height : 192,
				lang : 'zh-CN',
				followingToolbar: false,
				callbacks: {
	                onImageUpload: function (files) {
	                    sendFile(files[0], this);
	                }
	            }
		    });
			var content = $("#question").val();
		    $('#editorQuestion').summernote('code', content);
	    });
	    
	    // 上传文件
	    function sendFile(file, obj) {
	        var data = new FormData();
	        data.append("file", file);
	        $.ajax({
	            type: "POST",
	            url: ctx + "common/upload",
	            data: data,
	            cache: false,
	            contentType: false,
	            processData: false,
	            dataType: 'json',
	            success: function(result) {
	                if (result.code == web_status.SUCCESS) {
	                	$(obj).summernote('editor.insertImage', result.url, result.fileName);
					} else {
						$.modal.alertError(result.msg);
					}
	            },
	            error: function(error) {
	                $.modal.alertWarning("图片上传失败。");
	            }
	        });
	    }
        
        $("#form-question-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
            	var sHTML = $('.summernoteQuestion').summernote('code');
				$("#question").val(sHTML);
                $.operate.save(prefix + "/edit", $('#form-question-edit').serialize());
            }
        }

     /*    $("input[name='repairTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        }); */
    </script>
</body>
</html>